Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

comfy-mongo

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

comfy-mongo

Run a full-fledged MongoDB server with one line of code. No download or setup. Just, require("comfy-mongo")();

  • 1.1.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3
decreased by-76.92%
Maintainers
1
Weekly downloads
 
Created
Source

ComfyMongoDB

Easiest way to setup MongoDB! Run a full-fledged MongoDB server with one line of code. No download or setup. Just, require("comfy-mongo")();

For those of us that don't want to download and install MongoDB on the computer or for those who need a self-contained version inside a limited directory, ComfyMongoDB lets you start up a full MongoDB service SUPER EASILY in just one line of code.

Instafluff

For more coding fun like this Comfy MongoDB Module, come and hang out with us at the Comfiest Corner on Twitch!

https://twitch.tv/instafluff

https://twitter.com/instafluffTV

Instructions

  1. Install comfy-mongo
npm install comfy-mongo --save
  1. Start MongoDB and listen for events
var ComfyMongo = require("comfy-mongo")();
ComfyMongo.on( "ready", () => {
	console.log( "MongoDB is ready!" );
});
  1. Connect and use MongoDB
var ComfyMongo = require("comfy-mongo")();
ComfyMongo.on( "ready", () => {
	console.log( "MongoDB is ready!" );
	connectToMongoDB( "mongodb://localhost:27017" );
});

const MongoClient = require('mongodb').MongoClient;
function connectToMongoDB( url ) {
	MongoClient.connect( url, { useNewUrlParser: true }, ( err, client ) => {
		console.log("Connected successfully to server");
		client.close();
	});
}

Running MongoDB Globally

If you would simply like to run an instance of MongoDB, you can install ComfyMongoDB globally and run a CLI command.

  1. Install comfy-mongo globally
npm install -g comfy-mongo
  1. Start MongoDB from console
comfy-mongo

Connecting to MongoDB

The MongoDB server will start on port 27017 and can be connected to with the url: mongodb://localhost:27017

For an example connection, take a look at example.js!

Events

Currently, the MongoDB events available are:

  • readyComfyMongo.on( "ready", () => {} )
    • MongoDB is ready for connections
  • outputComfyMongo.on( "output", ( data ) => {} )
    • Stdout output stream
  • errorComfyMongo.on( "error", ( err ) => {} )
    • Stderr output stream
  • closeComfyMongo.on( "close", ( code ) => {} )
    • MongoDB has exited/closed with status code

Supported Platforms

ComfyMongoDB currently works in Windows and Mac/OSX.

MongoDB Version

ComfyMongoDB currently runs MongoDB Community Edition v4.0.10

How to Specify Your Own Database Directory

ComfyMongoDB defaults to ./data for storage.

To specify your own data directory, you can pass the file path in as a parameter:

var ComfyMongo = require("comfy-mongo")( "./MyCustomDirectory" );

Keywords

FAQs

Package last updated on 28 Apr 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc